001    package videoautomat;
002    import java.util.Date;
003    
004    import log.LogEntry;
005    import sale.Shop;
006    /**
007     * This class implements a <code>LogEntry</code> that describes the rent or hand back of a video.
008     */
009    public class LogEntryVideo extends LogEntry {
010    
011            /*
012             * The name of the user who rented or handed back a video.
013             */
014            private String user_ID;
015    
016            /*
017             * The name of the relevant video.
018             */
019            private String video_name;
020    
021            /*
022             * True if this entry logs a rent event, otherwise false.
023             */
024            private boolean rented;
025    
026            /*
027             * The date of logging.
028             */
029            private Date date;
030    
031            /**
032             * Constructs a new <code>LogEntryVideo</code> by the given params and the current date.
033             * 
034             * @param user_ID
035             *                  the ID of the relevant user
036             * @param video
037             *                  the name of the relevant video
038             * @param rented
039             *                  choose true if this entry should log a rent event, otherwise false
040             */
041            public LogEntryVideo(String user_ID, String video, boolean rented) {
042                    this.user_ID = user_ID;
043                    this.video_name = video;
044                    this.rented = rented;
045                    date = (Date) Shop.getTheShop().getTimer().getTime();
046            }
047    
048            /**
049             * @return a <code>String</code> representing whether who has rented or who gave back which video.
050             * 
051             * @see java.lang.Object#toString()
052             */
053            public String toString() {
054                    String s = " gave back ";
055                    if (rented)
056                            s = " has rented ";
057                    return ("The user " + user_ID + s + video_name);
058            }
059    
060            /**
061             * @return the date of logging.
062             * 
063             * @see log.LogEntry#getLogDate()
064             */
065            public Date getLogDate() {
066                    return date;
067            }
068    }